package my.hnb.android.view.dialog;

import my.hnb.android.dto.OptionItemDTO;
import my.hnb.android.listenner.OnEventListener;
import my.hnb.songnhac.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;

public class DialogOptionRow extends LinearLayout {
	OnEventListener listener;
	Context mContext;
	LinearLayout llRow;
	public TextView tvText;
	public CheckBox cbCheck;

	public DialogOptionRow(Context context) {
		super(context);
		mContext = context;
		LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view = inflater.inflate(R.layout.layout_dialog_option_row, this);
		
		tvText = (TextView) view.findViewById(R.id.tvText);
		cbCheck = (CheckBox) view.findViewById(R.id.cbCheck);
	}


	public void setValueMenu(String text, boolean isCheck){
		tvText.setText(text);
		cbCheck.setChecked(isCheck);
	}
	
	
	public void populateFrom(OptionItemDTO item) {
		if (item != null) {
			tvText.setText(item.getTextMenu());
			cbCheck.setChecked(item.isSelected());
		}
	}

	public void setBackground(int res) {
		if (llRow != null)
			llRow.setBackgroundResource(res);
	}
}
